package com.ruoyi.printer_auth_records.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.printer_auth_records.domain.PrinterAuthRecords;
import com.ruoyi.printer_auth_records.service.IPrinterAuthRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 打印机认证记录Controller
 * 
 * @author ruoyi
 * @date 2025-02-28
 */
@RestController
@RequestMapping("/printer_auth_records/printer_auth_records")
public class PrinterAuthRecordsController extends BaseController
{
    @Autowired
    private IPrinterAuthRecordsService printerAuthRecordsService;

    /**
     * 查询打印机认证记录列表
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrinterAuthRecords printerAuthRecords)
    {
        startPage();
        List<PrinterAuthRecords> list = printerAuthRecordsService.selectPrinterAuthRecordsList(printerAuthRecords);
        return getDataTable(list);
    }

    /**
     * 导出打印机认证记录列表
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:export')")
    @Log(title = "打印机认证记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PrinterAuthRecords printerAuthRecords)
    {
        List<PrinterAuthRecords> list = printerAuthRecordsService.selectPrinterAuthRecordsList(printerAuthRecords);
        ExcelUtil<PrinterAuthRecords> util = new ExcelUtil<PrinterAuthRecords>(PrinterAuthRecords.class);
        util.exportExcel(response, list, "打印机认证记录数据");
    }

    /**
     * 获取打印机认证记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(printerAuthRecordsService.selectPrinterAuthRecordsById(id));
    }

    /**
     * 新增打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:add')")
    @Log(title = "打印机认证记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrinterAuthRecords printerAuthRecords)
    {
        return toAjax(printerAuthRecordsService.insertPrinterAuthRecords(printerAuthRecords));
    }

    /**
     * 修改打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:edit')")
    @Log(title = "打印机认证记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrinterAuthRecords printerAuthRecords)
    {
        return toAjax(printerAuthRecordsService.updatePrinterAuthRecords(printerAuthRecords));
    }

    /**
     * 删除打印机认证记录
     */
    @PreAuthorize("@ss.hasPermi('printer_auth_records:printer_auth_records:remove')")
    @Log(title = "打印机认证记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(printerAuthRecordsService.deletePrinterAuthRecordsByIds(ids));
    }
}
